package com.jt.controller;

import com.jt.pojo.ServiceItems;
import com.jt.service.ServiceItemsService;
import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/serviceitems")
public class ServiceItemController {
    @Autowired
    private ServiceItemsService itemsService;

    //展示服务列表
    @GetMapping("/getServiceitemsList")
    public SysResult getServiceitemsList(PageResult pageResult){
        pageResult = itemsService.getServiceitemsList(pageResult);
        return SysResult.success(pageResult);
    }

    //新增服务项目
    @PostMapping("/addServiceitems")
    public SysResult addServiceitems(@RequestBody ServiceItems serviceItems){
        itemsService.addServiceitems(serviceItems);
        return SysResult.success();
    }

    //服务状态修改
    @PutMapping("/status/{id}/{status}")
    public SysResult updateServiceitemsStatus(ServiceItems serviceItems){
        itemsService.updateServiceitemsStatus(serviceItems);
        return SysResult.success();
    }

    //服务项目修改
    @GetMapping("/{id}")
    public SysResult getServiceitems(@PathVariable Integer id){
       ServiceItems serviceItems = itemsService.getServiceitems(id);
       return SysResult.success(serviceItems);
    }
    @PutMapping("/updateServiceitems")
    public SysResult updateServiceitems(@RequestBody ServiceItems serviceItems){
        itemsService.updateServiceitems(serviceItems);
        return SysResult.success();
    }

    //服务删除
    @DeleteMapping("/{id}")
    public SysResult deleteServiceitems(@PathVariable Integer id){
        itemsService.deleteServiceitems(id);
        return SysResult.success();
    }


}
